#include<iostream>
using namespace std;
#include<vector>
#include<unordered_map>
#include<string>
class TimeMap {
public:
    unordered_map<string, vector<pair<int, string>>> ma;
    TimeMap() {

    }

    void set(string key, string value, int timestamp) {
        ma[key].emplace_back(timestamp, value);
    }
    string get(string key, int timestamp) {
        vector<pair<int, string>>& vec = ma[key];
        if (vec.size() == 0)
            return "";
        int left = 0, right = vec.size() - 1;
        while (left < right) {
            int mid = left + (right - left + 1) / 2;
            if (vec[mid].first <= timestamp)
                left = mid;
            else
                right = mid - 1;
        }
        if (vec[left].first <= timestamp)
            return vec[left].second;
        return "";
    }
};

/**
 * Your TimeMap object will be instantiated and called as such:
 * TimeMap* obj = new TimeMap();
 * obj->set(key,value,timestamp);
 * string param_2 = obj->get(key,timestamp);
 */